from app.mysqlfuntion.mysqlfuntion import queryid
import requests
import json
dataid=70000000
while True:
    requests.adapters.DEFAULT_RETRIES = 5
    print("id")
    print(dataid)
    data=queryid(dataid)
    if data!=None:
        print(data)
        for k in data:

            resdata=[
                dict(
                    idfa=k.idfa,
                    ip=k.ip,
                    ua=k.ua,
                    url="http://iosapps.itunes.apple.com/apple-assets-us-std-000001/Purple115/v4/c6/0a/bb/c60abbbf-9393-00ec-0eb4-3811339ef963/pre-thinned" +
                        k.key+ ".thinned.signed.dpkg.ipa?accessKey=1531669847_8578225660183103978_iUdy5%2BzHsQmVq5QmPP2DIdeh%2FDd95ULRsQJ2h48PnpgLDqPrnLA4Ocsk2A0qVs0HBh6%2F4wd8tkHNbbVIPoPH2o%2FmfXYiAkPT%2BGzjaw0%2BOejPPuYjLUTiT1NHrTuTlGIvIB4dyvrbVymCeFjzvF7vvqLGetizRAxXtjG2gdPVt8DW9O5jU2W5vdJx5kPVaCxAJSAloweVVncUg%2B%2BF1sizxu%2B1s%2F0LatPeVEdJH5VR4IA%3D"

                )
            ]
            res=dict(
                data=resdata,
                time=k.time
            )
            res = json.dumps(res).encode("utf-8").decode('unicode_escape')
            print(res)
            dataid=dataid+1
            url = 'http://172.18.22.50:8802/json?channel=5'
            body = data
            headers = {'content-type': "application/json"}
            response = requests.post(url, data =res, headers = headers)
            s = requests.session()
            s.keep_alive = False
        else:
            print("数据为空")
            dataid = dataid + 1